import yaml
class hyaml:
   def create_yml(self,filename,data):
      with open(filename, 'w', encoding='utf-8') as f:
         yaml.dump(data, stream=f, allow_unicode=True)


   def show_yml(self):
      with open('./test_create1.yml', 'r', encoding='utf-8') as f:
         result = yaml.load(f.read(), Loader=yaml.FullLoader)
         print(result, type(result))
         return result

# if __name__ == '__main__':
#    myyaml=hyaml()
#    apiData = {
#       "page": 1,
#       "msg": "地址",
#       "data": [{
#          "id": 1,
#          "name": "学校"
#       }, {
#          "id": 2,
#          "name": "公寓"
#       }, {
#          "id": 3,
#          "name": "流动人口社区"
#       }],
#    }
#    myyaml.create_yml('abc.yaml',apiData)
#    myyaml.show_yml()
